﻿using DoNet.Core;
using DoNet.System.Models;

namespace DoNet.System.IRepositories
{
    /// <summary>
    /// 组织仓储接口
    /// 这里用到的Organize业务对象，是领域对象
    /// </summary>
    public interface IOrganizeRepository : IRepository<Organize>
    {
        #region 同步方法

        #region 修改
        #region 数据有效性
        /// <summary>
        /// 同步根据主键Id设置数据有效性
        /// </summary>
        /// <param name="enabledMark">有效性标识 DeleteMark设置为true有效 false无效</param>
        /// <param name="lastModifyUserId">最后操作人Id</param>
        /// <param name="lastModifyTime">最后操作时间</param>
        /// <param name="id">主键</param>
        /// <returns></returns>
        bool SetEnabledMark(bool enabledMark, long lastModifyUserId, DateTime lastModifyTime, long id);
        /// <summary>
        /// 同步根据主键Id列表设置数据有效性
        /// </summary>
        /// <param name="enabledMark">有效性标识 DeleteMark设置为true有效 false无效</param>
        /// <param name="lastModifyUserId">最后操作人Id</param>
        /// <param name="lastModifyTime">最后操作时间</param>
        /// <param name="ids">主键Id列表</param>
        /// <returns></returns>
        bool SetEnabledMark(bool enabledMark, long lastModifyUserId, DateTime lastModifyTime, IEnumerable<long> ids);
        /// <summary>
        /// 同步根据条件设置数据有效性
        /// </summary>
        /// <param name="enabledMark">有效性标识 DeleteMark设置为true有效 false无效</param>
        /// <param name="lastModifyUserId">最后操作人Id</param>
        /// <param name="lastModifyTime">最后操作时间</param>
        /// <param name="whereSql">条件语句 如："Age > @Age"</param>
        /// <param name="parameters">条件参数 如：new { Age = 30 }</param>
        /// <returns>返回影响的行数</returns>
        bool SetEnabledMark(bool enabledMark, long lastModifyUserId, DateTime lastModifyTime, string whereSql = "", object? parameters = null);
        #endregion 数据有效性
        #region 逻辑删除
        /// <summary>
        /// 同步根据主键Id逻辑删除信息
        /// </summary>
        /// <param name="deleteMark">软删除标识 deleteMark设置为true删除 false未删除</param>
        /// <param name="deleteUserId">删除人Id</param>
        /// <param name="deleteTime">删除时间</param>
        /// <param name="id">主键</param>
        /// <returns></returns>
        bool SetDeleteMark(bool deleteMark, long deleteUserId, DateTime deleteTime, long id);
        /// <summary>
        /// 同步根据主键Id列表逻辑删除信息
        /// </summary>
        /// <param name="deleteMark">软删除标识 deleteMark设置为true删除 false未删除</param>
        /// <param name="deleteUserId">删除人Id</param>
        /// <param name="deleteTime">删除时间</param>
        /// <param name="ids">主键Id列表</param>
        /// <returns></returns>
        bool SetDeleteMark(bool deleteMark, long deleteUserId, DateTime deleteTime, IEnumerable<long> ids);
        /// <summary>
        /// 同步根据条件逻辑删除信息
        /// </summary>
        /// <param name="deleteMark">软删除标识 deleteMark设置为true删除 false未删除</param>
        /// <param name="deleteUserId">删除人Id</param>
        /// <param name="deleteTime">删除时间</param>
        /// <param name="whereSql">条件语句 如："Age > @Age"</param>
        /// <param name="parameters">条件参数 如：new { Age = 30 }</param>
        /// <returns>返回影响的行数</returns>
        bool SetDeleteMark(bool deleteMark, long deleteUserId, DateTime deleteTime, string whereSql = "", object? parameters = null);
        #endregion 逻辑删除
        #endregion 修改

        #region 查询
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        IEnumerable<Organize> GetListByIds(IEnumerable<long> ids);
        /// <summary>
        /// 根据节点Id获取子节点集合
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        IEnumerable<Organize> GetChildListById(long id);
        /// <summary>
        /// 根据节点Id获取父节点集合
        /// </summary>
        /// <param name="pid"></param>
        /// <returns></returns>
        IEnumerable<Organize> GetParentListById(long id);
        /// <summary>
        /// 获取父集，递归调用
        /// </summary>
        /// <param name="data"></param>
        /// <param name="id">Id</param>
        /// <returns></returns>
        IEnumerable<Organize> GetParentOrganizes(IEnumerable<Organize> data, long id);
        /// <summary>
        /// 获取子集，递归调用
        /// </summary>
        /// <param name="data"></param>
        /// <param name="parentId">父级Id</param>
        /// <returns></returns>
        IEnumerable<Organize> GetChiltOrganizes(IEnumerable<Organize> data, long parentId);
        #endregion 查询

        #endregion 同步方法

        #region 异步方法

        #region 修改
        #region 数据有效性
        /// <summary>
        /// 异步根据主键Id设置数据有效性
        /// </summary>
        /// <param name="enabledMark">有效性标识 DeleteMark设置为true有效 false无效</param>
        /// <param name="lastModifyUserId">最后操作人Id</param>
        /// <param name="lastModifyTime">最后操作时间</param>
        /// <param name="id">主键</param>
        /// <returns></returns>
        Task<bool> SetEnabledMarkAsync(bool enabledMark, long lastModifyUserId, DateTime lastModifyTime, long id);
        /// <summary>
        /// 异步根据主键Id列表设置数据有效性
        /// </summary>
        /// <param name="enabledMark">有效性标识 DeleteMark设置为true有效 false无效</param>
        /// <param name="lastModifyUserId">最后操作人Id</param>
        /// <param name="lastModifyTime">最后操作时间</param>
        /// <param name="ids">主键Id列表</param>
        /// <returns></returns>
        Task<bool> SetEnabledMarkAsync(bool enabledMark, long lastModifyUserId, DateTime lastModifyTime, IEnumerable<long> ids);
        /// <summary>
        /// 异步根据条件设置数据有效性
        /// </summary>
        /// <param name="enabledMark">有效性标识 DeleteMark设置为true有效 false无效</param>
        /// <param name="lastModifyUserId">最后操作人Id</param>
        /// <param name="lastModifyTime">最后操作时间</param>
        /// <param name="whereSql">条件语句 如："Age > @Age"</param>
        /// <param name="parameters">条件参数 如：new { Age = 30 }</param>
        /// <returns>返回影响的行数</returns>
        Task<bool> SetEnabledMarkAsync(bool enabledMark, long lastModifyUserId, DateTime lastModifyTime, string whereSql = "", object? parameters = null);
        #endregion 数据有效性
        #region 逻辑删除
        /// <summary>
        /// 异步根据主键Id逻辑删除信息
        /// </summary>
        /// <param name="deleteMark">软删除标识 deleteMark设置为true删除 false未删除</param>
        /// <param name="deleteUserId">删除人Id</param>
        /// <param name="deleteTime">删除时间</param>
        /// <param name="id">主键</param>
        /// <returns></returns>
        Task<bool> SetDeleteMarkAsync(bool deleteMark, long deleteUserId, DateTime deleteTime, long id);
        /// <summary>
        /// 异步根据主键Id列表逻辑删除信息
        /// </summary>
        /// <param name="deleteMark">软删除标识 deleteMark设置为true删除 false未删除</param>
        /// <param name="deleteUserId">删除人Id</param>
        /// <param name="deleteTime">删除时间</param>
        /// <param name="ids">主键Id列表</param>
        /// <returns></returns>
        Task<bool> SetDeleteMarkAsync(bool deleteMark, long deleteUserId, DateTime deleteTime, IEnumerable<long> ids);
        /// <summary>
        /// 异步根据条件逻辑删除信息
        /// </summary>
        /// <param name="deleteMark">软删除标识 deleteMark设置为true删除 false未删除</param>
        /// <param name="deleteUserId">删除人Id</param>
        /// <param name="deleteTime">删除时间</param>
        /// <param name="whereSql">条件语句 如："Age > @Age"</param>
        /// <param name="parameters">条件参数 如：new { Age = 30 }</param>
        /// <returns>返回影响的行数</returns>
        Task<bool> SetDeleteMarkAsync(bool deleteMark, long deleteUserId, DateTime deleteTime, string whereSql = "", object? parameters = null);
        #endregion 逻辑删除
        #endregion 修改

        #region 查询
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        Task<IEnumerable<Organize>> GetListByIdsAsync(IEnumerable<long> ids);
        /// <summary>
        /// 根据节点Id获取子节点集合
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<IEnumerable<Organize>> GetChildListByIdAsync(long id);
        /// <summary>
        /// 根据节点Id获取父节点集合
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<IEnumerable<Organize>> GetParentListByIdAsync(long id);
        /// <summary>
        /// 异同步获取父集，递归调用
        /// </summary>
        /// <param name="data"></param>
        /// <param name="id">Id</param>
        /// <returns></returns>
        Task<IEnumerable<Organize>> GetParentOrganizesAsync(IEnumerable<Organize> data, long id);
        /// <summary>
        /// 异步获取子集，递归调用
        /// </summary>
        /// <param name="data"></param>
        /// <param name="parentId">父级Id</param>
        /// <returns></returns>
        Task<IEnumerable<Organize>> GetChiltOrganizesAsync(IEnumerable<Organize> data, long parentId);
        #endregion 查询

        #endregion 异步方法
    }
}
